# -*- coding: utf-8 -*-
from odoo import models, api, fields, tools
from odoo.exceptions import UserError
import re


class soil_monitoring(models.Model):

    _name = "datcent.soil_monitoring"
    _description = "土壤"
    _table = "datcent_soil_monitoring"
    _order = "sequence"
    _inherit =  ['mail.thread', 'mail.activity.mixin', 'image.mixin']

    sequence = fields.Integer(string="排序",translate = 0)
    name = fields.Char(string="土壤名称",translate = 0)
    datetime = fields.Datetime(string="日期时间",translate = 0)
    soil_category_id = fields.Many2one(string="土壤类型",comodel_name = 'datcent.soil_category',translate = 0)
    indicator_id = fields.Many2one(string="监测指标",comodel_name = 'datcent.data_indicator',translate = 0)
    value = fields.Char(string="监测值",translate = 0)
    detail_contents = fields.Html(string="详细说明",translate = 0)
    state = fields.Selection(string="状态",selection = [('1', '草稿'), ('2', '提交'), ('3', '审核')],default='1',translate = 0)

    def button1(self):
        if self.state == '1':
            self.write({'state': '2'})
        # 审核
    def button2(self):
        if self.state == '2':
            self.write({'state': '3'})
        # 退回
    def button3(self):
        if self.state == '2':
            self.write({'state': '1'})

        # 反审核
    def button4(self):
        if self.state == '3':
            self.write({'state': '2'})
